<?php
require_once '../sub/init.php';
if(!is_mobile())header("Location: ".a('{"kind":"vip"}'));
$currfields = 'sex,grade,sjtime,sjtime2,money,vipnum,nickname';
$chk_u_jumpurl=$jumpurl;
require_once ZEAI.'m/my_chk_u.php';
require_once ZEAI.'cache/config_vip.php';
require_once ZEAI.'cache/config_sms.php';
require_once ZEAI.'cache/udata.php';
$cook_grade = intval($row['grade']);
$cook_sex   = intval($row['sex']);
$cook_sjtime  = intval($row['sjtime']);
$cook_sjtime2 = intval($row['sjtime2']);
$cook_money   = $row['money'];
$cook_vipnum  = $row['vipnum'];
$cook_nickname  = trimhtml(dataIO($row['nickname'],'out'));
$switch          =json_decode($_ZEAI['switch'],true);
$urole           = json_decode($_ZEAI['urole'],true);
$chat_loveb      = json_decode($_VIP['chat_loveb'],true);
$chat_daylooknum = json_decode($_VIP['chat_daylooknum'],true);
$contact_loveb      = json_decode($_VIP['contact_loveb'],true);
$contact_daylooknum = json_decode($_VIP['contact_daylooknum'],true);
$loveb_buy          = json_decode($_VIP['loveb_buy'],true);
$photo_num          = json_decode($_VIP['photo_num'],true);
$video_num          = json_decode($_VIP['video_num'],true);
$sj_rmb1            = json_decode($_VIP['sj_rmb1'],true);
$sj_rmb2            = json_decode($_VIP['sj_rmb2'],true);
$vipC               = json_decode($_VIP['vipC'],true);
$chat_duifangfree   = json_decode($_VIP['chat_duifangfree'],true);
$sj_loveb   = json_decode($_VIP['sj_loveb'],true);
$viewlist   = json_decode($_VIP['viewlist'],true);
$qianxian_num = json_decode($_VIP['qianxian_num'],true);
$hh_num = json_decode($_VIP['hh_num'],true);
$rz_num = json_decode($_VIP['rz_num'],true);
$rz_data = explode(',',$_ZEAI['rz_data']);
$datingadd = json_decode($_VIP['datingadd'],true);
$vip_num   = json_decode($_VIP['vip_num'],true);
if($submitok=='ajax_getvipauth'){
	if(!ifint($grade) || $grade>20 || $grade<1)json_exit(array('flag'=>0,'msg'=>'请选择套餐'));
	$C = '';
	if($switch['Smode']['g_'.$grade] == 1){
		$s1 = '<h6>专属VIP标识</h6>';
		$s2 = '<h6>线上自主联系</h6>';
		$C.= '<dl><dt><i class=ico>&#xe611;</i></dt><dd>'.$s1.$s2.'</dd></dl>';
		if($chat_duifangfree[$grade]==1 && @in_array('chat',$navarr)){
			$s1 = '<h6>专属对方绿色通道</h6>';
			$s2 = '<h6>发信对方免费看</h6>';
			$C.= '<dl><dt class=lvs><i class=ico>&#xe60c;</i></dt><dd>'.$s1.$s2.'</dd></dl>';
		}
		//
		$viewlist=$viewlist[$grade];
		if($viewlist==1){
			$s1 = '<h6>谁看过我</h6>';
			$s2 = '<h6>不错过喜欢你的人</h6>';
			$C.= '<dl><dt><i class=ico>&#xe8ab;</i></dt><dd>'.$s1.$s2.'</dd></dl>';
		}
		//
		$sj_loveb=$sj_loveb[$grade];
		$sj_loveb=($sj_loveb>0)?'免费送'.$_ZEAI['loveB'].'<b>'.$sj_loveb.'</b>个':'';
		if($loveb_buy[$grade]<1){
			$l = '<h6>充值'.$_ZEAI['loveB'].'<b>'.($loveb_buy[$grade]*10).'折</b></h6><h6>'.$sj_loveb.'</h6>';	
			$C.= '<dl><dt><i class=ico>&#xe618;</i></dt><dd>'.$l.'</dd></dl>';
		}
		if($contact_daylooknum[$grade]>0 && @in_array('contact',$navarr)){
			$s11 = '<h6>看联系方式每天<b>'.$contact_daylooknum[$grade].'</b>人</h6>';
			$s22 = ($contact_loveb[$grade]==0)?'<h6>查看免费</h6>':'<h6>联系<b>'.$contact_loveb[$grade].$_ZEAI['loveB'].'</b>/人</h6>';
			$C.= '<dl><dt><i class=ico>&#xe607;</i></dt><dd>'.$s11.$s22.'</dd></dl>';
		}
		if($chat_daylooknum[$grade]>0 && @in_array('chat',$navarr)){
			$s111 = '<h6>看信/聊天每天<b>'.$chat_daylooknum[$grade].'</b>人</h6>';
			$s222 = ($chat_loveb[$grade]==0)?'<h6>看信免费</h6>':'<h6>解锁<b>'.$chat_loveb[$grade].$_ZEAI['loveB'].'</b>/人</h6>';
			$C.= '<dl><dt><i class=ico>&#xe629;</i></dt><dd>'.$s111.$s222.'</dd></dl>';
		}
	}else{
		$s1 = '<h6>专属VIP标识</h6>';
		$s2 = '<h6>线下红娘1对1牵线</h6>';
		$C.= '<dl><dt><i class=ico>&#xe613;</i></dt><dd>'.$s1.$s2.'</dd></dl>';
	}
	$c1111=($qianxian_num[$grade] > 0)?'<h6>可自助申请牵线</h6>':'已关闭在线牵线<br>';
	$c2222=($qianxian_num[$grade] > 0)?'<h6>红娘1对1牵线<b>'.$qianxian_num[$grade].'</b>次</h6>':'自己加红娘微信咨询';
	$C.= '<dl><dt><i class=ico>&#xe613;</i></dt><dd>'.$c1111.$c2222.'</dd></dl>';
	
	if($hh_num[$grade]>0 && @in_array('contact_hh',$navarr)){
		$c='<h6>线上发起互换微信手机</h6><h6>赠送<b>'.$hh_num[$grade].'</b>次机会</h6>';
		$C.= '<dl><dt><i class=ico>&#xe691;</i></dt><dd>'.$c.'</dd></dl>';
	}
	
	if($rz_num[$grade]>0 && ($_SMS['rz_mobile3']==1 && in_array('identity',$rz_data) || in_array('photo',$rz_data))  ){
		$c='<h6>实名认证和真人认证</h6><h6>赠送<b>'.$rz_num[$grade].'</b>次免费机会</h6>';
		$C.= '<dl><dt><i class=ico>&#xe66b;</i></dt><dd>'.$c.'</dd></dl>';
	}
	if($datingadd[$grade]>0 && @in_array('dating',$navarr)){
		$c='<h6>发布1+1约会</h6><h6>免费</h6>';
		$C.= '<dl><dt><i class=ico>&#xe6a9;</i></dt><dd>'.$c.'</dd></dl>';
	}
	
	if($switch['sh']['moddata_'.$grade] == 1 || $switch['sh']['photom_'.$grade] == 1){
		$c1=($switch['sh']['moddata_'.$grade] == 1)?'<h6>修改资料直接通过</h6>':'<br>';
		$c2=($switch['sh']['photom_'.$grade] == 1)?'<h6>上传头像直接通过</h6>':'<br>';
		$C.= '<dl><dt><i class=ico>&#xe619;</i></dt><dd>'.$c1.$c2.'</dd></dl>';
	}
	if(@in_array('video',$navarr)){
		$c11=($switch['sh']['video_'.$grade] == 1)?'<h6>上传视频直接通过</h6>':'上传视频需要审核<br>';
		$c22='<h6>视频容量<b>'.$video_num[$grade].'</b>个</h6>';
		$C.= '<dl><dt><i class=ico>&#xe68a;</i></dt><dd>'.$c11.$c22.'</dd></dl>';
	}
	$c111=($switch['sh']['photo_'.$grade] == 1)?'<h6>上传相册直接通过</h6>':'上传相册需要审核<br>';
	$c222='<h6>相册容量<b>'.$photo_num[$grade].'</b>张</h6>';
	$C.= '<dl><dt><i class=ico>&#xe648;</i></dt><dd>'.$c111.$c222.'</dd></dl>';
	
	$vipC = $vipC[$grade];
	$vipC=str_replace("%","％",$vipC);
	json_exit(array('flag'=>1,'C'=>$C,'vipC'=>$vipC));
}elseif($submitok=='ajax_chk_vipnum'){
	if(!ifint($grade) || $grade>20 || $grade<1)json_exit(array('flag'=>0,'msg'=>'请选择套餐'));
	if(!empty($cook_vipnum)){
		$cook_vip_num = json_decode($cook_vipnum,true);
		if(@count($cook_vip_num)>0 && is_array($cook_vip_num)){
			$cook_vipnum = intval($cook_vip_num[$grade]);
			if($cook_vipnum >= $vip_num[$grade] && $vip_num[$grade]>0)json_exit(array('flag'=>0,'msg'=>'当前【'.utitle($grade).'】限购'.$vip_num[$grade].'次<br>您已购买过'.$cook_vipnum.'次，请选择其他套餐'));
		}
	}
	json_exit(array('flag'=>1,'msg'=>'ok'));
}
$safetips = dataIO($_VIP['safetips'],'out');
$newarr=array();$n=1;$defG=2;
foreach($urole as $RV){
	if($RV['f']==1 && $RV['g']>1){
	$newarr[]=$RV;
	if($n==1){
		$def_grade=$RV['g'];
		$def_if2=$RV['if2'];
		$def_price = ($cook_sex==2)?$sj_rmb2[$def_grade.'_'.$def_if2]:$sj_rmb1[$def_grade.'_'.$def_if2];
	}
	}else{continue;}
	$n++;
}
$vipclosestr='在线支付已关闭';
if(count($newarr)<=0){
	$ifpay = false;
}else{
	$ifpay=true;
	$urole=$newarr;
	sort($urole);$maxkey=max($urole);$maxg= $maxkey['g'];$maxif2= $maxkey['if2'];
	//$diff=$cook_sjtime2-$cook_sjtime;
	//if($cook_grade>=$maxg && $diff>=315360000){$ifpay = false;$vipclosestr='土豪，您已经是最顶级VIP，无需升级！';}
}
if(!ifint($cook_sex)){$ifpay = false;$vipclosestr='您的性别不详或资料还未通过审核<br>暂时无法升级！';}
$maxprice = ($cook_sex==2)?$sj_rmb2[$maxg.'_'.$maxif2]:$sj_rmb1[$maxg.'_'.$maxif2];
$nav='my';
$kf_tel=dataIO($_ZEAI['kf_tel'],'out');$kf_wxpic=dataIO($_ZEAI['kf_wxpic'],'out'); $kf_mob=dataIO($_ZEAI['kf_mob'],'out');
$jumpurlback = (!empty($jumpurl))?'zeai.openurl(\''.urldecode($jumpurl).'\')':'zeai.back()';
if($_ZEAI['m_mb']==2){require_once ZEAI.'m/my_vip2.php';exit;}?>
<!doctype html><html><head><meta charset="utf-8">
<title>VIP会员服务-<?php echo $_ZEAI['siteName'];?></title>
<?php echo HEADMETA; ?>
<link href="<?php echo RES;?>m/css/m.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<link href="<?php echo RES;?>m/css/my_vip.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo HOST;?>/cache/zeaicolor.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<style>
.viplist button{box-shadow:0 3px 8px rgba(57,63,87,.4);color:#e1cba2;background-color:#393F57}
.btmKefuBtn{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
#backtop a{background-color:#fff;color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.viplist .CC b,.viplist .auth dl dd h6 b,.viplist .table tr td.on{color:<?php echo $_ZEAI['mob_mbcolor'];?>}
</style>
<?php
$wxshareT   = 'VIP收银台';
$wxshareC   = '开通VIP，畅通无极限，享受红娘一对一人工服务！';
$wxshareURL = mHref('vip');
$wxsharePIC = RES.'m/img/share_vip.png?'.$_ZEAI['cache_str'];
if (is_weixin()){
	require_once ZEAI."api/weixin/jssdk.php";?>
	<script src="<?php echo RES; ?>jweixin-1.2.0.js"></script>
	<script>
	wx.config({debug:false,appId: '<?php echo $signPackage["appId"];?>',timestamp: <?php echo $signPackage["timestamp"];?>,nonceStr:'<?php echo $signPackage["nonceStr"];?>',signature: '<?php echo $signPackage["signature"];?>',jsApiList:['hideMenuItems','onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo','previewImage']});
	var FX_title = '<?php echo trimhtml($wxshareT);?>',
	FX_desc  = '<?php echo trimhtml($wxshareC).'【'.$_ZEAI['siteName'].'】';?>',
	FX_link  = '<?php echo $wxshareURL; ?>',
	FX_imgurl= '<?php echo $wxsharePIC; ?>';
	wx.ready(function () {
		wx.onMenuShareAppMessage({title:FX_title,desc:FX_desc,link:FX_link,imgUrl:FX_imgurl});
		wx.onMenuShareTimeline({title:FX_title,link:FX_link,imgUrl:FX_imgurl});
	});
	</script>
<?php }?>
</head>
<body>
<i class='ico goback gobackVip' onClick="<?php echo $jumpurlback;?>">&#xe602;</i>
<div class="my_vip">
    <?php if (!empty($_VIP['vipbanner'])){?><div class="vipheader"<?php echo (!empty($_VIP['vipbanner_url']))?' onclick="zeai.openurl(\''.$_VIP['vipbanner_url'].'\')"':'';?>><img src="<?php echo UP.$_VIP['vipbanner'];?>"></div><?php }else{?>
    <div class="vipheader"><img src="<?php echo RES.'m/img/vipbn.jpg';?>"></div>
    <?php }
	if($cook_grade>1){
		$vipcls='style="margin-top:0"';
		?>
		<div class="my_vip_self">
			您当前：<?php echo utitle($cook_grade);?>（<?php echo YmdHis($cook_sjtime,'Ymd');?> ~ <?php echo YmdHis($cook_sjtime2,'Ymd');?>）
		</div>
   <?php }
	if ($ifpay){?>
    <div class="viplist"<?php echo $vipcls;?>>
        <!--<h1><img src="<?php echo RES;?>m/img/my_vip_Ticoleft.png">购买VIP服务<img src="<?php echo RES;?>m/img/my_vip_Ticoright.png"></h1>-->
        <?php
        foreach($urole as $RV){
            $g = $RV['g'];$f = $RV['f'];
            $if2 = $RV['if2'];
            if($g<=1 || $f!=1)continue;
            //if($cook_grade > $g )continue;
            $pic_url = UP.'p/img/grade'.$cook_sex.$g.'.png?'.$_ZEAI['cache_str'];
			$price = ($cook_sex==2)?$sj_rmb2[$g.'_'.$if2]:$sj_rmb1[$g.'_'.$if2];
			$dayprice=round($price/$if2,2);
			$dayprice=($dayprice>0)?' 日均'.$dayprice.'元':'';
            ?>
            <table class="table">
              <tr>
                <td width="50" align="left" valign="middle"><img class="gico" src="<?php echo $pic_url;?>"></td>
                <td align="left"><b><?php echo utitle($g); ?></b><em><?php echo $if2.'天'.$dayprice;?></em></td>
                <td align="left" class="vippricebox <?php echo ($maxg == $g)?' on':'off';?>" id="vipprice<?php echo $g;?>"><?php echo '￥'.$price;?></td>
                <td width="40" align="left"><input onClick="vipFn(<?php echo $g;?>,<?php echo $if2;?>,encodeURIComponent('<?php echo utitle($g); ?>'),<?php echo $price;?>)" type="checkbox" id="vip<?php echo $g;?>" name="vip<?php echo $g;?>" class="checkskin vipli"<?php echo ($maxg == $g)?' checked':'';?>><label for="vip<?php echo $g;?>" class="checkskin-label"><i class="i3"></i></label> </td>
            </tr>
            </table>
        <?php }?>
        <div class="clear"></div>
        <button type="button" class="btn size4 B" id="vipbtn">确认购买</button><br>
    </div>
    <div class="viplist viplist2">
    	<h1><img src="<?php echo RES;?>m/img/my_vip_Ticoleft.png"><font id="gradename"><?php echo utitle($maxg);?>特权</font><img src="<?php echo RES;?>m/img/my_vip_Ticoright.png"></h1>
        <div class="CC auth" id="auth">
        	<ul id="vipauth"></ul>
    		<div class="clear"></div>
    	</div>
        <i class="ico off morebtn" onClick="morebtn(this);">展开更多特权 &#xe60b;</i>
    </div>
    <div class="viplist" id="vipCbox">
    	<h1><img src="<?php echo RES;?>m/img/my_vip_Ticoleft.png"><font id="gradename2"><?php //echo utitle($maxg);?>套餐详情</font><img src="<?php echo RES;?>m/img/my_vip_Ticoright.png"></h1>
        <div class="CC" id="vipC"></div>
    </div>
    <?php }else{?>
    	<div class="viplist lineH200"><br><br><?php echo $vipclosestr;?><br>
        	<div class="my-subscribe_box" style="display:block"><img src="<?php echo UP.$kf_wxpic;?>" style="width:30%"><h3>长按二维码加客服微信咨询<br><br><br><br></h3></div>
        </div>
    <?php }?>
    <div class="clear"></div>
<br><br>
</div>

<a href="javascript:;" id="btmKefuBtn" class="btmKefuBtn" onClick="ZeaiM.div({obj:btmKefuBox,w:26,h:28});"><i class="ico">&#xe6a6;</i>客服</a>
<div id="btmKefuBox" class="my-subscribe_box"><img src="<?php echo UP.$kf_wxpic;?>"><h3>长按二维码添加客服微信<br>咨询红娘1对1人工牵线</h3></div>

<?php if ($ifpay){?>
    <input type="hidden" name="grade" id="grade" value="<?php echo $maxg;?>">
    <input type="hidden" name="if2" id="if2" value="<?php echo $maxif2;?>">
    <script src="<?php echo RES;?>m/js/my_vip.js?<?php echo $_ZEAI['cache_str'];?>"></script>
    <script>
    var maxg=<?php echo $maxg;?>;
    vipbtn.onclick=function(){
        if (!zeai.ifint(grade.value) || !zeai.ifint(if2.value) ){zeai.msg('请选择VIP会员类型');return false;}
		if (o('money').value<=0){zeai.msg('请选择');return false;}
		zeai.ajax({url:HOST+'/m/my_vip'+zeai.extname,data:{submitok:'ajax_chk_vipnum',grade:grade.value}},function(e){var rs=zeai.jsoneval(e);
			if(rs.flag==1){
				money=o('money').value;o('money_str').html('￥'+money);
				ZeaiM.div_up({obj:czbox,h:<?php echo (is_weixin())?30.5:37.5;?>});
				if(cook_money >= o('money').value && cook_money>0){
					o('rmbbox').class('on');
					o('money_tips').html('可用余额￥'+cook_money);
					o('rmbpay').disabled="";
					rmbpay.onclick = function(){
						paykind.value = 'rmbpay';
						payListener(this);
					}
				}else{
					o('rmbbox').class('off');
					o('money_tips').html('当前￥'+cook_money+'，账户余额不足');
					o('rmbpay').disabled="true";
					o('rmbpay').checked=false;
				}
			}else{
				zeai.msg(rs.msg,{time:5});
			}
		});
    }
    setTimeout(function(){getvipauth(<?php echo $maxg;?>);},600);
    document.body.onscroll = supdes_vip;
    </script>
    <?php
		$jump_url = (!empty($jumpurl))?urldecode($jumpurl):HOST.'/m/my.php';
		$money = $maxprice;
		$kind  = 1;
		echo '<input type="hidden" id="money" value="'.$money.'">';
		require_once 'my_pay.php';
	?>
<?php }?>
<div id="backtop"><a href="#top" id="btmTopBtn"><i class="ico">&#xe60c;</i>顶部</a></div>
<div class="blank"></div>
</body>
</html>
<?php 
if($_ZEAI['m_mb']==2){
	require_once ZEAI.'m/bottom2.php';
}else{
	require_once ZEAI.'m/bottom.php';
}
?>